<template>
  <div>
    <vab-query-form>
      <vab-query-form-left-panel>
        <el-button icon="el-icon-plus" type="primary" @click="dialogFormVisible = true">
          添加
        </el-button>
        <el-button icon="el-icon-delete" type="danger" @click="handleDelete">
          删除
        </el-button>
      </vab-query-form-left-panel>
      <vab-query-form-right-panel>
        <el-form ref="form" :model="queryForm" :inline="true" @submit.native.prevent>
          <el-form-item>
            <el-input v-model="queryForm.informationIntention" placeholder="学生Id" />
          </el-form-item>
          <el-form-item>
            <el-button icon="el-icon-search" type="primary" native-type="submit" @click="handleQuery">
              查询
            </el-button>
          </el-form-item>
        </el-form>
      </vab-query-form-right-panel>
      </vab-query-form>
    <el-table ref="multipleTable" :data="examgrade" tooltip-effect="dark" style="width: 100%" v-loading="listLoading"
      :element-loading-text="elementLoadingText" @selection-change="handleSelectionChange">
      <el-table-column show-overflow-tooltip type="selection" width="55"></el-table-column>
      <el-table-column prop="studentId" label="学生ID">
      </el-table-column>
      <el-table-column prop="theoryGrade" label="理论成绩">
      </el-table-column>
      <el-table-column prop="skillGrade" label="技能成绩">
      </el-table-column>
      <el-table-column prop="isCheat" label="是否作弊">
      </el-table-column>
      <el-table-column prop="clazzId" label="班级ID">
      </el-table-column>
      <el-table-column prop="courseId" label="课程ID">
      </el-table-column>
      <!--      <el-table-column prop="informationImg" label="简历个人照片">
        <template slot-scope="scope">
          <img v-if="scope.row.informationImg" :src="scope.row.informationImg" width="50px" height="50px">
        </template>
      </el-table-column> -->
      <el-table-column show-overflow-tooltip label="操作" width="180px">
        <template #default="{ row }">
          <el-button type="text" @click="handleEdit(row)">修改状态</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination :background="background" :current-page="queryForm.current" :layout="layout"
      :page-size="queryForm.size" :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange">
    </el-pagination>


  </div>
</template>

<script>
  import {
    getStudentByCollageId
  } from '@/api/student.js'
  export default {
    name: 'studentInfo',
    data() {
      return {
        collageId: 0,
        examgrade: [],
        pages: 0,
        layout: 'total, sizes, prev, pager, next, jumper',
        background: true,
        multipleSelection: [],
        listLoading: true,
        elementLoadingText: '正在加载...',
        total: 0,
        queryForm: {
          current: 1,
          size: 5,
          paramMap: {
            collageId: ''
          },
        },
      }
    },
    computed: {

      height() {
        return this.$baseTableHeight()
      },
    },
    created() {
      //学院ID
      window.sessionStorage.setItem("schoolId", "1440285428262379522");
      this.queryForm.paramMap.collageId = window.sessionStorage.getItem("schoolId");
    },

    mounted() {
      this.queryForm.paramMap.collageId = window.sessionStorage.getItem("schoolId")
      console.log("schooleId:", this.queryForm.paramMap.collageId)
      getStudentByCollageId(this.queryForm).then(data => {
        if (data.code == 200) {
          this.listLoading = false
          this.examgrade = data.data.records
          this.total = parseInt(data.data.total)
          this.queryForm.size = parseInt(data.data.size)
          this.queryForm.current = parseInt(data.data.current)

        } else {
          this.$baseMessage(data.msg, 'error')
        }
      })

    },
    methods: {

      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      //添加
      handleAdd() {

      },
      //编辑 开启隐藏页面 赋值
      handleEdit(row) {

      },
      handleDelete(){

      },
      //页面改变
      handleSizeChange(val) {
        this.queryForm.size = val
        this.queryForm.paramMap.collageId = window.sessionStorage.getItem("schoolId")
        console.log("schooleId:", this.queryForm.paramMap.collageId)
        getStudentByCollageId(this.queryForm).then(data => {
          if (data.code == 200) {

            this.listLoading = false
            this.examgrade = data.data.records
            this.total = parseInt(data.data.total)
            this.queryForm.size = parseInt(data.data.size)
            this.queryForm.current = parseInt(data.data.current)

          } else {
            this.$baseMessage(data.msg, 'error')
          }
        })
      },
      handleCurrentChange(val) {
        this.queryForm.current = val
        this.queryForm.paramMap.collageId = window.sessionStorage.getItem("schoolId")
        console.log("schooleId:", this.queryForm.paramMap.collageId)
        getStudentByCollageId(this.queryForm).then(data => {
          if (data.code == 200) {
            this.listLoading = false
            this.examgrade = data.data.records
            this.total = parseInt(data.data.total)
            this.queryForm.size = parseInt(data.data.size)
            this.queryForm.current = parseInt(data.data.current)

          } else {
            this.$baseMessage(data.msg, 'error')
          }
        })
      },
    }
  }
</script>

<style>
</style>
